package com.example.a10908.retorfitrxjava.ui.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ListView;
import android.widget.Toast;

import com.example.a10908.retorfitrxjava.R;
import com.example.a10908.retorfitrxjava.model.bean.ListBean;
import com.example.a10908.retorfitrxjava.presenter.Presenter_Main;
import com.example.a10908.retorfitrxjava.ui.adapter.MianListViewAdapter;
import com.example.a10908.retorfitrxjava.ui.view.MianView;

public class MainActivity extends AppCompatActivity implements MianView {

    private ListView listView;
    private Presenter_Main presenter_main;
    private MianListViewAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        listView = (ListView) findViewById(R.id.listView);
        presenter_main = new Presenter_Main(this);
        presenter_main.setNetWorkpath("{\"menu\":0}");

    }

    @Override
    public void setListBean(ListBean listBean) {
//        Log.e("list", listBean.getData().size() + "");
        adapter = new MianListViewAdapter(this, listBean.getData());
        listView.setAdapter(adapter);
    }

    @Override
    public void httpError(String e) {
        Toast.makeText(this, e, Toast.LENGTH_SHORT).show();
    }
}
